import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Item {
    id: configBack_ConfigWindow
    width: 1760
    height: 935


    property real button_Width: 180
    property real button_Height: 60
    property real buttonFontPixle: 20
    property real fontSize: Cpp_Language.CurrentLanguage === 1 ? 40 : Cpp_Language.CurrentLanguage === 2 ? 25 : Cpp_Language.CurrentLanguage === 3 ? 25 : 40


    property bool sawPushTimeFlag: Cpp_PLC.M_528        // 工进时间 标志位
    property bool knobModeFlag: Cpp_PLC.M_510           // 旋钮选择 标志位
    property bool solenoidValvePowerFlag: Cpp_PLC.M_509 // 电磁阀断电 标志位
    property bool codeModeFlag: Cpp_PLC.M_400           // 编码器    标志位
    property bool printerExistFlag: Cpp_PLC.M_398       // 打印机存在    标志位
    property bool bracketExistFlag: Cpp_PLC.M_397       // 托料架存在  标志位
    property bool autoObersveExistFlag: Cpp_PLC.M_396   // 自动测高存在 标志位
    property bool sawOutSwingInSwingFlag: Cpp_PLC.M_394 // 锯片外摆内摆 标志位
    property bool scramFlag: Cpp_PLC.M_500              // 急停按钮常开常闭 标志位
    property bool servoWarningFlag: Cpp_PLC.M_501       // 伺服报警常开常闭 标志位

    property bool servoTypeFlag: Cpp_PLC.M_392          // 伺服类型 标志位
    property bool knobChooseFlag: Cpp_PLC.M_393         // 旋钮选择左右锯 标志位
    property bool limitSwitchFlag: Cpp_PLC.M_502        // 限位开关常开常闭 标志位
    property bool mechineKnobFlag: Cpp_PLC.M_503        // 机头旋钮常开常闭 标志位
    property bool pullForbidFlag: Cpp_PLC.M_529         // 拉手禁用启用 标志位
    property bool saw45SpecialFlag: Cpp_PLC.M_530       // 45度转切 标志位
    property bool servoNameFlag: Cpp_PLC.M_505          // 伺服名称类型 标志位
    property bool sawsScanFlag : Cpp_PLC.M_506          // 锯片防扫料 标志位
    property bool impactTypeFlag: Cpp_PLC.M_507         // 压紧正反逻辑 标志位
    property bool resetKeyDelayFlag: Cpp_PLC.M_508      // 复位延时 标志位


    Column{         // 左侧列表
        anchors.left: configBack_ConfigWindow.left
        anchors.leftMargin: 200
        anchors.top: configBack_ConfigWindow.top
        anchors.topMargin: 20

        spacing: 10

        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: sawPushTimeFlag ? qsTr("工进时间分开") :qsTr("工进时间共用")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50
                checked: sawPushTimeFlag
                onSwitchButtonClicked: {
                    if(sawPushTimeFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(528,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(528,true)
                    }
                }

            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: knobModeFlag ? qsTr("旋钮选择角度") :qsTr("旋钮选择机头")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: knobModeFlag
                onSwitchButtonClicked: {
                    if(knobModeFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(510,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(510,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: solenoidValvePowerFlag ? qsTr("电磁阀断电") :qsTr("电磁阀不断电")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: solenoidValvePowerFlag
                onSwitchButtonClicked: {
                    if(solenoidValvePowerFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(509,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(509,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: codeModeFlag ? qsTr("编码器17位") :qsTr("编码器21位")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: codeModeFlag
                onSwitchButtonClicked: {
                    if(codeModeFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(400,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(400,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: printerExistFlag ? qsTr("打印机存在") :qsTr("打印机不存在")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: printerExistFlag
                onSwitchButtonClicked: {
                    if(printerExistFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(398,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(398,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: bracketExistFlag ? qsTr("托料架存在") :qsTr("托料架不存在")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: bracketExistFlag
                onSwitchButtonClicked: {
                    if(bracketExistFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(397,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(397,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: autoObersveExistFlag ? qsTr("自动测高存在") :qsTr("自动测高不存在")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: autoObersveExistFlag
                onSwitchButtonClicked: {
                    if(autoObersveExistFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(396,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(396,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: sawOutSwingInSwingFlag ? qsTr("锯片内摆") :qsTr("锯片外摆")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: sawOutSwingInSwingFlag
                onSwitchButtonClicked: {
                    if(sawOutSwingInSwingFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(394,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(394,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: scramFlag ? qsTr("急停按钮常开") :qsTr("急停按钮常闭")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: scramFlag
                onSwitchButtonClicked: {
                    if(scramFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(500,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(500,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: servoWarningFlag ? qsTr("伺服报警常开") :qsTr("伺服报警常闭")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: servoWarningFlag
                onSwitchButtonClicked: {
                    if(servoWarningFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(501,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(501,true)
                    }
                }
            }
        }

    }





    Column{         // 右侧列表
        anchors.right: configBack_ConfigWindow.right
        anchors.rightMargin: 200
        anchors.top: configBack_ConfigWindow.top
        anchors.topMargin: 20

        spacing: 10


        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: servoTypeFlag ? qsTr("绝对值伺服") :qsTr("增量式伺服")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: servoTypeFlag
                onSwitchButtonClicked: {
                    if(servoTypeFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(392,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(392,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: knobChooseFlag ? qsTr("触屏选择左右锯") :qsTr("旋钮选择左右锯")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: knobChooseFlag
                onSwitchButtonClicked: {
                    if(knobChooseFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(393,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(393,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: limitSwitchFlag ? qsTr("限位开关常闭") :qsTr("限位开关常开")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: limitSwitchFlag
                onSwitchButtonClicked: {
                    if(limitSwitchFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(502,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(502,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: mechineKnobFlag ? qsTr("机头旋钮常闭") :qsTr("机头旋钮常开")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50                           

                checked: mechineKnobFlag
                onSwitchButtonClicked: {
                    if(mechineKnobFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(503,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(503,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: pullForbidFlag ? qsTr("拉手启用") :qsTr("拉手禁用")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: pullForbidFlag
                onSwitchButtonClicked: {
                    if(pullForbidFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(529,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(529,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: saw45SpecialFlag ? qsTr("45度专切启用") :qsTr("45度专切禁用")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: saw45SpecialFlag
                onSwitchButtonClicked: {
                    if(saw45SpecialFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(530,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(530,true)

                        Cpp_PLC.write_into_PLC_Coils(13,true)
                        Cpp_PLC.write_into_PLC_Coils(13,false)
                        Cpp_PLC.write_into_PLC_Coils(14,true)
                        Cpp_PLC.write_into_PLC_Coils(14,false)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: servoNameFlag ? qsTr("DVS伺服") :qsTr("TH伺服")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: servoNameFlag
                onSwitchButtonClicked: {
                    if(servoNameFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(505,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(505,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: sawsScanFlag ? qsTr("防扫料启用") :qsTr("防扫料禁用")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: sawsScanFlag
                onSwitchButtonClicked: {
                    if(sawsScanFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(506,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(506,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: impactTypeFlag ? qsTr("压紧反逻辑") :qsTr("压紧正逻辑")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: impactTypeFlag
                onSwitchButtonClicked: {
                    if(impactTypeFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(507,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(507,true)
                    }
                }
            }
        }
        Item{
            width: 500
            height: 80

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: resetKeyDelayFlag ? qsTr("复位延时开") :qsTr("复位延时关")
                }

            }

            A_SwitchButton{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 310
                trackHeight: 50

                checked: resetKeyDelayFlag
                onSwitchButtonClicked: {
                    if(resetKeyDelayFlag)
                    {
                        Cpp_PLC.write_into_PLC_Coils(508,false)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(508,true)
                    }
                }
            }
        }




    }


}
